home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-10-07 | 3.5 KB | 129 lines | [TEXT/KAHL] |
- /* some functions to respond to various user inputs...
- * 870806-13-... ^z
- */
-
- #include <stdio.h> /* for FILE, printf(), etc. */
- #include <strings.h> /* for strcpy(), etc. */
- #include <unix.h> /* for exit(), etc. */
- #include <proto.h> /* for function prototypes */
- #include "brwsr.h" /* for various definitions */
- #include "brwsr.proto.h" /* for my function prototypes */
-
-
- /* function to print out helpful information -- a command summary
- * for the user....
- */
-
- void do_help ()
- {
- printf (" ? print this help\n");
- printf (" : quit the program\n");
- printf (" :fnord open document file 'fnord' for browsing\n");
- printf (" >grok open notes file 'grok' and append output\n");
- printf (" > close notes file\n");
- printf (" 'DON.MAC append comment 'DON.MAC' to notes file\n");
- printf (" xyzzy jump to 'XYZZY' in INDEX\n");
- printf (" \".123 jump to '.123' in INDEX\n");
- printf (" -17 back up 17 lines\n");
- printf (" - back up one line\n");
- printf (" +0 print current line\n");
- printf (" <return> move down one line\n");
- printf (" +23 move down 23 lines\n");
- printf (" = INDEX --> CONTEXT --> TEXT\n");
- printf (" ^ INDEX <-- CONTEXT <-- TEXT\n");
- printf (" .9 move down and print out 9 lines\n");
- printf (" * create an empty working subset\n");
- printf (" ** fill the working subset (complete database)\n");
- printf (" & add word-neighborhood to subset\n");
- printf (" && add sentence-neighborhood to subset\n");
- printf (" &&& add paragraph-neighborhood to subset\n");
- printf (" ~ invert (logical NOT) entire working subset\n");
- printf (" ; repeat previous command\n");
- }
-
-
- /* function to handle a ":" command, to either quit the program or to
- * open a new database for browsing.... display some amusing data
- * about the file that is opened, if successful (total length in bytes,
- * total number of words, and number of unique words in the file)...
- */
-
- void do_open (cmd)
- char cmd[];
- {
- char qcmd[STRLEN];
- extern FILE *doc_file;
- extern long max_item[];
- void destroy_subset (), open_files (), init_items ();
-
- if (cmd[1] == '\0')
- {
- printf ("Quit?\n");
- gets (qcmd);
- if (qcmd[0] == 'y' || qcmd[0] == 'Y')
- {
- printf ("Good-bye ... ^z\n");
- exit ();
- }
- else
- {
- printf ("Cancelled!\n");
- return;
- }
- }
-
- destroy_subset ();
- open_files (cmd);
- if (doc_file == NULL)
- return;
- init_items ();
- printf ("File \"%s\" contains:\n", cmd + 1);
- printf ("%9ld characters\n%9ld total words\n%9ld unique words\n",
- max_item[TEXT] + 1, max_item[CONTEXT] + 1, max_item[INDEX] + 1);
- }
-
-
- /* function to open or close a notes file ... copies of browser
- * program output gets appended to that notes file as long as it
- * is open, and the user may add comment strings with the '"' command ....
- */
-
- void do_redirection (cmd)
- char cmd[];
- {
- extern FILE *notes_file;
- FILE *fopen ();
-
- if (notes_file != NULL)
- fclose (notes_file);
-
- if (cmd[1] == '\0')
- return;
-
- if ((notes_file = fopen (cmd + 1, "a")) == NULL)
- {
- beep ();
- printf ("Error opening notes file \"%s\"!\n", cmd + 1);
- return;
- }
- }
-
-
- /* function to append a comment line to the notes_file... does the job
- * for the '"' command....
- */
-
- void do_comments (cmd)
- char cmd[];
- {
- extern FILE *notes_file;
-
- if (notes_file == NULL)
- {
- beep ();
- printf ("No notes file open!\n");
- return;
- }
- else
- fprintf (notes_file, "%s\n", cmd + 1);
- }